package org.jeecg.modules.iot.mqtt.server.service.processor.carOperate;

import org.jeecg.modules.iot.jtt808.JTT808Encoder;
import org.jeecg.modules.iot.jtt808.JTT808Message;
import org.jeecg.modules.iot.mqtt.entity.Packet;
import org.jeecg.modules.iot.model.Jt808Control.Jt808CentralControlConfig;
import org.jeecg.modules.iot.model.modbus.ModbusParams;
import org.jeecg.modules.iot.mqtt.server.service.processor.JT808MessageGenerator;
import org.jeecg.modules.iot.mqtt.server.service.processor.MessageType;
import org.springframework.stereotype.Component;

import static org.jeecg.modules.iot.utils.JT808Utils.bytesToHexString;

@Component
public class ClearRemoteControlMessageGenerator implements JT808MessageGenerator {
    // ... (与 RemoteControlPairMessageGenerator 结构类似, 命令字改为 0xB1)

    @Override
    public String generateMessage(JTT808Message message) {
        message.id = 0x8105; // 终端控制消息 ID
        message.packetCount = 0;
        message.packetIndex = 0;

        Packet p = Packet.create(1);
        p.addByte((byte) 0xB1); // 命令字: 清空遥控器 (0xB1)

        message.body = p.getBytes();
        return bytesToHexString(JTT808Encoder.encode(message));
    }

    @Override
    public String generateMessage(JTT808Message message, Jt808CentralControlConfig config) {
        message.id = 0x8105; // 终端控制消息 ID
        message.packetCount = 0;
        message.packetIndex = 0;

        Packet p = Packet.create(1);
        p.addByte((byte) 0xB1); // 命令字: 清空遥控器 (0xB1)

        message.body = p.getBytes();
        return bytesToHexString(JTT808Encoder.encode(message));
    }

    @Override
    public String generateMessage(JTT808Message message, ModbusParams params) {
        return "";
    }

    @Override
    public String getType() {
        return MessageType.CLEAR_REMOTE_CONTROL.name(); // 定义新的消息类型
    }

    // ... 其他方法保持接口一致性
}